import 'package:animations/animations.dart';
import 'package:cat_eye/base/base_refresh_state.dart';
import 'package:cat_eye/root_page/find_page/find_special_details_widget.dart';
import 'package:cat_eye/root_page/home_page/video_details_widget.dart';
import 'package:cat_eye/util/util.dart';
import 'package:cat_eye/view_model/find_view_model/find_special_view_model.dart';
import 'package:flutter/material.dart';

/*
* @Package: root_page.find_page
* @ClassName: find_special_widget
* @Author: szj
* @CreateDate: 8/2/21 7:08 PM
* TODO 发现-专题页面
*/
class FindSpecialWidget extends StatefulWidget {
  const FindSpecialWidget({Key key}) : super(key: key);

  @override
  _FindSpecialWidgetState createState() => _FindSpecialWidgetState();
}

class _FindSpecialWidgetState
    extends BaseRefreshState<FindSpecialWidget, FindSpecialViewModel> {
  @override
  FindSpecialViewModel get buildViewModel => FindSpecialViewModel();

  @override
  Widget buildWidget(BuildContext context, FindSpecialViewModel model) {
    return ListView.builder(
        itemCount: model.itemList.length,
        itemBuilder: (context, index) {
          return OpenContainer(
            openBuilder: (BuildContext context,
                void Function({Object returnValue}) action) {
              return FindSpecialDetailsWidget(
                  id: model.itemList[index].data.id);
            },
            closedBuilder: (BuildContext context, void Function() action) {
              return Padding(
                padding: EdgeInsets.only(left: 10, right: 10, top: 10),
                child: cacheImage(model.itemList[index].data.image,
                    width: MediaQuery.of(context).size.width,
                    height: 180,
                    borderRadius: BorderRadius.circular(8)),
              );
            },
          );
        });
  }
}
